package com.itqf.service.impl;

import com.itqf.mapper.DtsGoodsMapper;
import com.itqf.mapper.DtsGoodsProductMapper;
import com.itqf.mapper.DtsOrderMapper;
import com.itqf.mapper.DtsUserMapper;
import com.itqf.service.DashboardService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.HashMap;
import java.util.Map;

/**
 * projectName: shop_manage
 *
 * @author: MaTianWei
 * time: 2021/7/14 15:12
 * description:
 */
@Service
public class DashboardServiceImpl implements DashboardService {
    //首页数据展示 用户数据 货物数据 库存数据 订单数据

    @Autowired
    private DtsUserMapper dtsUserMapper;
    @Autowired
    private DtsGoodsMapper dtsGoodsMapper;
    @Autowired
    private DtsGoodsProductMapper dtsGoodsProductMapper;
    @Autowired
    private DtsOrderMapper dtsOrderMapper;

    //log4j日志
    public static final Logger logger = LoggerFactory.getLogger(DashboardService.class);

    @Override
    public Map showDashboard() {
        Long godsTotal = dtsGoodsMapper.queryTotal();
        Long userTotal = dtsUserMapper.queryTotal();
        Long productTotal = dtsGoodsProductMapper.queryTotal();
        Long orderTotal = dtsOrderMapper.queryTotal();

        logger.debug("[首页数量展示]查询货物数量：{},用户数量：{},库存数量：{},订单数量：{}",godsTotal,userTotal,productTotal,orderTotal);

        Map data = new HashMap();
        data.put("godsTotal",godsTotal);
        data.put("userTotal",userTotal);
        data.put("productTotal",productTotal);
        data.put("orderTotal",orderTotal);

        logger.info("[首页数据展示]业务执行完毕，返回数据为：{}");

        return data;
    }

}
